﻿#pragma once
#include "../logdef.h"
#include "logbase.h"

NAMESPACE_BEG

class LoggerCustPrinterMgr {
public:
    static LoggerCustPrinterMgr& getInstance() {
        static LoggerCustPrinterMgr mgr;
        return mgr;
    }
    ~LoggerCustPrinterMgr() {

    }
    void setDisplayFormat(int format) {
        format_ = format;
    }
public:
    void addDevcie(Device* dev) {
        dev_list_.push_back(dev);
    }
    void print(const LogItem& item) {

        for (auto it : dev_list_) {
            it->print(item.property_.level_,
                item.property_.file_,
                item.property_.func_,
                item.property_.line_,
                item.property_.time_.time_since_epoch().count(),
                (char*)item.log_.c_str());
        }
    }

private:
    LoggerCustPrinterMgr() {

    }
private:
    std::vector<Device* > dev_list_;
    int format_ = 127;

};

NAMESPACE_END
